package com.homework;

public class demo08 {
    public static void main(String[] args) {
        //定义数组
        int[] arr = new int[]{1, 4, 3, 4, 5, 4, 7, 9, 7, 3, 2, 5, 7, 9, 3, 4, 5, 7};
        //计数器记录奇数的个数
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 != 0) {
                count++;
            }
        }
        System.out.println(count);
        //动态初始化一个数组用来接收排序后的arr
        int[] arr1 = new int[arr.length];
        //定义索引,记录奇数
        int index1 = 0;
        //定义索引,记录偶数
        int index2 = 0;
        //遍历arr，按照要求放置到指定位置
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 == 1) {
                arr1[index1] = arr[i];
                index1++;
            } else {
                System.out.println(i);
                System.out.println(count + index2);
                arr1[count + index2] = arr[i];
                index2++;
            }
        }
        for (int i = 0; i < arr1.length; i++) {
            System.out.print(arr1[i] + " ");
        }
    }
}